﻿@model Sispe.Entities.DERECHO_HABIENTE

@{
    ViewBag.Title = "Registro de Derecho Habiente";
}

<link rel="stylesheet" href="~/Content/bootstrap.min.css">
<link rel="stylesheet" href="~/Content/themes/base/jquery-ui.css">
<script src="~/Scripts/jquery-1.10.2.js"></script>
<script src="~/Scripts/jquery-ui.js"></script>



<div id="dialog" class="panel panel-default">
        <div class="panel-heading">Búsqueda de Derecho Habiente</div>
        <div class="panel-body">
            <b>Criterio :  </b>@Html.TextBox("BuscarPersona")
        </div>
        <div class="panel-footer"></div>
    </div>

<button type="submit" id="opener"  class="btn btn-default  btn-lg " value="Guardar">Buscar Persona</button>


<script>
    $(function () {
        $("#dialog").dialog({
            autoOpen: false,
            width: 450,
            height: 250,
            modal: true,
            show: {
                effect: "toggle",
                duration: 800
            },
            hide: {
                effect: "toggle",
                duration: 800
            }
        });

        $("#opener").click(function () {
            $("#dialog").dialog("open");
        });
    });
</script>

<script>
    $(function () {
        $("#BuscarPersona").autocomplete({
            source: function (request, response) {
                $.ajax({
                    url: '@Url.Action("Search")', type: "POST", dataType: "json",
                    data: { nombrePersona: request.term },
                    success: function (data) {
                        response($.map(data, function (item) {
                            return { label: item.label, value: item.id };
                        }));
                    }
                });
            },
            select: function (event, ui) {
                $("#BuscarPersona").val("");
                $("#Id_Persona").val(ui.item.value);
                alert("Ha seleccionado la persona : " + ui.item.label);
                $("#PersonaSeleccionada").val(ui.item.label);
                $("#dialog").dialog("close");
                return false;
            }
        });
    });

</script>



@using (Html.BeginForm()) {
    @Html.AntiForgeryToken()
    @Html.ValidationSummary(true)

    <fieldset>
        <legend>CONDICIONES</legend>
        <div class="editor-field">@Html.Hidden("IdTrabajador")</div>

        <div class="editor-field"><b>Trabajador: </b></div>
        <input type="text" readonly="true" value="@Html.Value("TRABAJADOR")" />

        <br /><br />
        <b>Activo: </b>@Html.EditorFor(model => model.Activo)
        @Html.ValidationMessageFor(model => model.Activo)

        
        <br /><br />
        <b>Constancia Física: </b>@Html.EditorFor(model => model.ConstanciaFisica)
        @Html.ValidationMessageFor(model => model.ConstanciaFisica)

        <br /><br />
                <b>Doc. Sustenta: </b>@Html.DropDownList("IdDocumentoSustenta")
        
        <br /><br />
        <b>PERSONA:</b> &nbsp;&nbsp;&nbsp;&nbsp;<input type="text" readonly="true" id="PersonaSeleccionada" name="PersonaSeleccionada" />
                @Html.Hidden("Id_Persona")

        <br /><br />
                <b>Vinc. Familiar : </b>@Html.DropDownList("IdVinculoFamiliar")

        <p>
            <input type="submit" value="Create" />
        </p>
    </fieldset>
}

<div>
    <a href="@Url.Action("Index", "DerechoHabiente", new { id = Html.Value("IdTrabajador") })">
                <img src ="@Url.Content("~/Images/back.png")" title="Volver a Condiciones" 
                    alt="Volver a Condiciones" /></a> 
</div>

    

@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
}
